
    $(function() {

        $("#tel").val(new configure().getUrlParam("user_id"));
        $("#tel")[0].focus();
        //获取短信验证码
        var validCode=true;
        $(".msgs").click (function  () {
            var tel= $("#tel").val();//手机号
            if(tel==""){
                $.toast('请输入手机号', 'forbidden'); return;
            }
            if(tel.length!=11){
                $.toast('请输入正确手机号', 'forbidden');return;
            }
            var params={};
            params.mobile=tel;
            var time=60; //60秒
            if (validCode) {
                validCode=false;
                $(".msgs").css("color","#818080");
                var params={};
                params.user_name=tel;
                new configure().connect(new configure().url_smk+"javaapi/smkuser-service/users/applyResetPwd","POST",params,function (data,status,txtErr) {
                    if(status=="success"){
                        if(data.code==0){
                            $.toptip(data.msg);
                            var t=setInterval(function  () {
                                time--;
                                $(".msgs").html(time+"秒");
                                if (time==0) {
                                    clearInterval(t);
                                    $(".msgs").html("重新获取");
                                    validCode=true;
                                    $(".msgs").css("color","#04be02");
                                }
                            },1000)
                        }else{
                            $.toptip(data.msg);
                        }
                    }else{
                        $.toptip(txtErr);
                    }

                })
            }

        })


        $("#showTooltips").click(function() {
            var user_name = $('#tel').val();
            var veri_code = $('#code').val();
            var password_new = $('#pwd').val();

            if(user_name==""){
                $.toast('请输入手机号', 'forbidden');return;
            }
            if(user_name.length!=11){
                $.toast('请输入正确手机号', 'forbidden');return;
            }
            else if(!veri_code || !/\d{6}/.test(veri_code)) { $.toast('请输入六位手机验证码', 'forbidden');return;}
            else if(!((/^[\w]{6,20}$/.test(password_new)) && !(/^\d+$/.test(password_new)) && !(/^[A-Za-z]+$/.test(password_new)))){$.toast('请设置6~20位数字和字母组合的密码', 'forbidden');return;}
            //注册
            var params={};
            params.veri_code=veri_code;
            params.user_name=user_name;
            params.password_new=password_new;

            new configure().connect(new configure().url_smk+"javaapi/smkuser-service/users/checkResetPwd","POST",params,function (data,status,txtErr) {
                if(status=="success"){

                    if(data.code==0000){
                        $.toast('修改成功', 'ok');
                        window.location.href="./login.html?"+"user_system="+new configure().getUrlParam("user_system")+"&open_id="+new configure().getUrlParam("open_id")+"&callback_url="+new configure().getUrlParam("callback_url");
                    }else{
                        $.toptip(data.msg);
                    }
                }else{
                    $.toptip(txtErr);
                }
            })

        });

    });
